<template>
	<view class="good">
		<ABanner :isSeach="false" :highLight="highLight" @sendNum="handleTab" :menuList="['我的点赞']"></ABanner>
		<view v-for="(item,index) in params.list" :key="index">
			<ABlogCard :item="item"></ABlogCard>
		</view>
		<view v-if="params.list.length==0" class="empty_container">
			<u-empty text="暂无点赞" mode="data" width="100%" iconSize="60" textSize="32"></u-empty>
		</view>
	</view>
</template>

<script>
	import {
		getGoodBlog
	} from '@/api/forum.js'
	export default {
		mounted() {
			// 重新获取数据
			uni.$on('reloadlist', () => {
				this.pageParams.pageNum = 1
				this.getList(this.pageParams, false)
			})
		},
		onLoad() {
			getGoodBlog().then(res => {
				this.params.list = res.data.list
			})
		},
		onReachBottom() {
			if (this.params.total !== this.params.list.length) {
				this.pageParams.pageNum += 1
				this.getList(this.pageParams)
			}
		},
		data() {
			return {
				params: {
					list: [],
					total: 0
				},
				pageParams: {
					pageNum: 1,
					pageSize: 5
				},
				num: 0
			}
		},
		methods: {
			getList(data, flag = true) {
				if (flag) {
					getGoodBlog(data).then(res => {
						this.params.total = res.data.total
						this.params.list = this.params.list.concat(res.data.list)
					})
				} else {
					getGoodBlog(data).then(res => {
						this.params.total = res.data.total
						this.params.list = res.data.list
					})
				}
			},
			handleGet(val) {
				this.num = val;
				console.log("当前num为：", val);
			}

		}

	}
</script>

<style lang="scss">
.empty_container {
	display: flex;
	justify-content: center;
	align-items: center;
	height: 60vh;

	.u-empty {
		height: 60vh;
	}
}

</style>